<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <title>JavaScript Library - Elliptic Curves And Pairings</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="style.css" rel="stylesheet" type="text/css" />
        <script src="BigInteger.js"></script>
        <script src="Classic.js"></script>
        <script src="Barrett.js"></script>
        <script src="Montgomery.js"></script>
        <script src="NullExponent.js"></script>
        <script src="RC4.js"></script>
        <script src="SecureRandom.js"></script>
        <script src="JSPoint.js"></script>
        <script src="JSField2.js"></script>
        <script src="JSField4.js"></script>
        <script src="JSField6.js"></script>
        <script src="JSField12.js"></script>
        <script src="JSParams.js"></script>
        <script src="JSCurve.js"></script>
        <script src="JSPoint2.js"></script>
        <script src="JSCurve2.js"></script>
        <script src="JSPairing.js"></script>
        <script src="JSTests.js"></script>
        <script type="text/javascript">
            function multiplyFp() {
                var test = new JSTests();
                var average = test.multiplyFp();
                document.getElementById("Result").innerHTML = "";
                var result = document.getElementById("Result");
                for (var i = 0; i < test.validBitsRange.length; i++) {
                    var para = document.createElement("p");
                    para.appendChild(document.createTextNode("Time average for MultiplyFp Operation " + average[i]/100 + " ms with " + test.validBitsRange[i] + " bits"));
                    result.appendChild(para);
                }
                document.getElementById("Body").insertBefore(result, document.getElementById("Body").childNodes[-1]);
            }

            function multiplyFp2() {
                var test = new JSTests();
                var average = test.multiplyFp2();
                document.getElementById("Result").innerHTML = "";
                var result = document.getElementById("Result");
                for (var i = 0; i < test.validBitsRange.length; i++) {
                    var para = document.createElement("p");
                    para.appendChild(document.createTextNode("Time average for MultiplyFp2 Operation " + average[i]/100 + " ms with " + test.validBitsRange[i] + " bits"));
                    result.appendChild(para);
                }
                document.getElementById("Body").insertBefore(result, document.getElementById("Body").childNodes[-1]);
            }

            function precomputedMultiplyFp() {
                var test = new JSTests();
                var average = test.precomputedMultiplyFp();
                document.getElementById("Result").innerHTML = "";
                var result_premultiply = document.getElementById("Result");
                for (var i = 0; i < test.validBitsRange.length; i++) {
                    var para = document.createElement("p");
                    para.appendChild(document.createTextNode("Time average for Optimal Pairing: " + average[i]/100 + " ms with " + test.validBitsRange[i] + " bits"));
                    result_premultiply.appendChild(para);
                }
                document.getElementById("Body").insertBefore(result_premultiply, document.getElementById("Body").childNodes[-1]);
            }

            function addFp() {
                var test = new JSTests();
                var average = test.addFp();
                document.getElementById("Result").innerHTML = "";
                var result = document.getElementById("Result");
                for (var i = 0; i < test.validBitsRange.length; i++) {
                    var para = document.createElement("p");
                    para.appendChild(document.createTextNode("Time average for addFp Operation " + average[i] + " us with " + test.validBitsRange[i] + " bits"));
                    result.appendChild(para);
                }
                document.getElementById("Body").insertBefore(result, document.getElementById("Body").childNodes[-1]);
            }

            function pairing() {
                var test = new JSTests();
                var average = test.pairing();
                document.getElementById("Result").innerHTML = "";
                var result_pairing = document.getElementById("Result");
                for (var i = 0; i < test.validBitsRange.length; i++) {
                    var para = document.createElement("p");
                    para.appendChild(document.createTextNode("Time average for Optimal Pairing: " + average[i]/10 + " ms with " + test.validBitsRange[i] + " bits"));
                    result_pairing.appendChild(para);
                }
                document.getElementById("Body").insertBefore(result_pairing, document.getElementById("Body").childNodes[-1]);
            }
        </script>
    </head>
    <body>
        <div id="Header">
            <h1>JavaScript Library For Encryption</h1>
        </div>
        <div id="Body">
            <p>This page is a demo of the Javascript Library For Encryption.</p>
            <table border="1">
                <tr>
                    <td>Scalar multiplication for random point on Fp</td>
                    <td><input type="button" id="multiplyFp" onclick="multiplyFp();" value="Calcule" /></td>
                </tr>
                <tr>
                    <td>Scalar multiplication for random point on Fp2</td>
                    <td><input type="button" id="multiplyFp2" onclick="multiplyFp2();" value="Calcule" /></td>
                </tr>
                <tr>
                    <td>Scalar multiplication for fixed point on Fp</td>
                    <td><input type="button" id="precomputedMultiplyFp" onclick="precomputedMultiplyFp();" value="Calcule" /></td>
                </tr>
                <tr>
                    <td>Addition for two different points on Fp</td>
                    <td><input type="button" id="addFp" onclick="addFp();" value="Calcule" /></td>
                </tr>
                <tr>
                    <td>Pairing</td>
                    <td><input type="button" id="pairing" onclick="pairing();" value="Calcule" /></td>
                </tr>
            </table>
            <div id="Result"></div>
        </div>
        <div id="Footer">
            <h4>Jorgenhoc - &copy; Copyright</h4>
        </div>
    </body>
</html>
